package com.haima.sage.bigdata.api.dao;

import com.haima.sage.bigdata.api.entity.ComputeTask;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Repository
public interface ComputeTaskRepository extends JpaRepository<ComputeTask, String> {
    @Modifying
    @Query("update ComputeTask o set o.name = :name, o.data = :data, o.description = :description, o.updateDate = :updateDate where o.id = :id")
    void updateBase(@Param("id") String id,
                @Param("name") String name,
                @Param("data") String data,
                @Param("description") String description,
                @Param("updateDate") Date updateDate);

    @Modifying
    @Query("update ComputeTask o set o.name = :name, o.data = :data  where o.id in :id")
    void update(@Param("id") String id,
                @Param("name") String name,
                @Param("data") String data);

    @Modifying
    @Query("update ComputeTask o set o.name = :name  where o.id = :id")
    void updateName(@Param("id") String id,
                    @Param("name") String name);

    @Modifying
    @Query("update ComputeTask o set o.data = :data, o.updateDate = :updateDate  where o.id = :id")
    void updateData(@Param("id") String id,
                    @Param("data") String data,
                    @Param("updateDate") Date updateDate);

}